﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DFASimulation
{
    public class DFAState
    {
        public int id
        {
            get;
            set;
        }
        public String desc
        {
            get;
            set;
        }
        internal List<DFAState> next
        {
            get;
            set;
        }
        internal List<char> rules
        {
            get;
            set;
        }

        public DFAState() { }

        public DFAState(int id, String desc)
        {
            this.id = id;
            this.desc = desc;
        }

        public DFAState getNext(char a)
        {
            DFAState nextState = null;
            for (int i = 0; i < rules.Capacity; i++)
            {
                if (rules.ElementAt(i) == a)
                {
                    nextState = next.ElementAt(i);
                    break;
                }
                else
                    continue;

            }
            if (nextState != null)
                return nextState;
            else
                throw new System.ArgumentNullException("No transition link has been set for this state");
        }
    }
}
